;Exercise 1.6.  Alyssa P. Hacker doesn't see why if needs to be provided as a special form.
; ``Why can't I just define it as an ordinary procedure in terms of cond?'' she asks.
; Alyssa's friend Eva Lu Ator claims this can indeed be done, and she defines a new version of if:

(define (average x y)
  (/ (+ x y) 2))

(define (improve guess x)
  (average guess (/ x guess)))

(define (good-enough? guess x)
  (< (abs (- (* guess guess) x)) 0.001))

(define (new-if predicate then-clause else-clause)
  (cond (predicate then-clause)
        (else else-clause)))

(define (sqrt-iter guess x)
  (new-if (good-enough? guess x)
          guess
          (sqrt-iter (improve guess x)
                     x)))



;The recursion is executed infinitely because the stopping instruction 'guess' is never reached).
;Our 'applicative-evaluation-interpreter' is to blame.
;It seems that the interpreter scans the whole sqrt-iter body to apply any function calls before verifying the conditions.